﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

public class MenuView : MonoBehaviour
{

    public GameObject Tittle;
    public GameObject Menu;

    public Button StartGameBtn;
    public Button GameInfoBtn;
    public Button GameMakerBtn;
    public Button ExitGameBtn;


	// Use this for initialization
	void Start ()
	{
        StartGameBtn.onClick.AddListener(StartGame);
        GameInfoBtn.onClick.AddListener(GameInfo);
        GameMakerBtn.onClick.AddListener(GameMaker);
        ExitGameBtn.onClick.AddListener(ExitGame);
    }

    void OnEnable()
    {
        Tittle.transform.DOLocalMoveX(0f, 1f);
        Menu.transform.DOLocalMoveY(-150, 1f);
    }

    void StartGame()
    {
        Disappear(() =>
        {
		    UIScenenManager.getInstance ().openSceneUI ();
		    UIManager.getInstance ().openDialog (new UIMain());
		    Destroy (gameObject);
            
        });
    }

    void GameInfo()
    {
        var go = Resources.Load<GameObject>("GameInfo");
        go = Instantiate(go);
        go.transform.SetParent(GameObject.Find("Canvas").transform);
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale = Vector3.one;
    }

    void GameMaker()
    {
        
    }

    void ExitGame()
    {
        
    }

    void Disappear(UnityAction callback)
    {
        Tittle.transform.DOLocalMoveX(-640f, 0.5f);
        Menu.transform.DOLocalMoveY(-750, 0.5f).OnComplete(() =>
        {
            if(callback!=null)callback.Invoke();
        });
    }
}
